package regex;

public class RegexTest {

    public static void main(String[] args) {

        String soureContent = "IF OBJECT_ID(N'[dbo].[MASK_STRING_SHADOW_ALL]', N'FN') IS NOT NULL DROP FUNCTION [dbo].[MASK_STRING_SHADOW_ALL]\n"
            + "GO\n"
            + "CREATE FUNCTION  [dbo].[MASK_STRING_SHADOW_ALL](\n"
            + "@Lv_inputData  [varchar](8000))\n"
            + "RETURNS [varchar](8000) AS\n"
            + "BEGIN\n"
            + "   RETURN REPLICATE('*',ISNULL(LEN(@Lv_inputData),0));\n"
            + "END;\n"
            + "GO";

        String[] splitSQL = soureContent.split("GO\\n");

        for (String s : splitSQL) {
            System.out.println("===>" + s);

            if (s.endsWith("GO")) {
                String huiche = s.substring(s.lastIndexOf("GO") - 1, s.lastIndexOf("GO"));
                String newS = s.endsWith("GO") ? s.substring(0, s.lastIndexOf("GO")) : s;
                System.out.println(newS);
            }
        }
        System.out.println(splitSQL.length);
    }

}
